def solve(n):
    k=0
    s=0
    while(s<=n):
        k+=1
        s+=(10**k-10**(k-1))*k
    s-=(10**k-10**(k-1))*k
    #print(s)
    r=n-s
    t=10**(k-1)+r//k
    print(k,r,t)
    if r%k==0: return int(str(t-1)[-1])
    return int(str(t)[r%k-1])

print('*',solve(19))
print('*',solve(13))
print('*',solve(5))